package casamento.controle;

  
  
import java.io.Serializable;  
import java.util.ArrayList;  
import java.util.List;  
import java.util.UUID;  
  
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;  
import org.primefaces.event.CellEditEvent;  

import casamento.Bean.TipoEstabelecimento;
  

  
public class TableBean implements Serializable {  
  
    private final static String[] colors;  
  
    private final static String[] manufacturers;  
  
    private List<TipoEstabelecimento> carsSmall;  
  
    static {  
        colors = new String[10];  
        colors[0] = "Black";  
        colors[1] = "White";  
        colors[2] = "Green";  
        colors[3] = "Red";  
        colors[4] = "Blue";  
        colors[5] = "Orange";  
        colors[6] = "Silver";  
        colors[7] = "Yellow";  
        colors[8] = "Brown";  
        colors[9] = "Maroon";  
  
        manufacturers = new String[10];  
        manufacturers[0] = "Mercedes";  
        manufacturers[1] = "BMW";  
        manufacturers[2] = "Volvo";  
        manufacturers[3] = "Audi";  
        manufacturers[4] = "Renault";  
        manufacturers[5] = "Opel";  
        manufacturers[6] = "Volkswagen";  
        manufacturers[7] = "Chrysler";  
        manufacturers[8] = "Ferrari";  
        manufacturers[9] = "Ford";  
    }  
  
    public TableBean() {  
        carsSmall = new ArrayList<TipoEstabelecimento>();  
  
        populateRandomCars(carsSmall, 9);  
    }  
  
    private void populateRandomCars(List<TipoEstabelecimento> list, int size) {  
        for(int i = 0 ; i < size ; i++)  
            list.add(new TipoEstabelecimento());  
    }  
  
  
    public String[] getManufacturers() {  
        return manufacturers;  
    }  
  
    public String[] getColors() {  
        return colors;  
    }  
  
    public void onCellEdit(CellEditEvent event) {  
        Object oldValue = event.getOldValue();  
        Object newValue = event.getNewValue();  
          
        if(newValue != null && !newValue.equals(oldValue)) {  
            FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Cell Changed", "Old: " + oldValue + ", New:" + newValue);  
            FacesContext.getCurrentInstance().addMessage(null, msg);  
        }  
    }  
}  